package com.joysw.ui;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ExpandableListView;
import butterknife.ButterKnife;
import butterknife.InjectView;

import com.joysw.R;
import com.joysw.ui.adapter.ExpandableListAdapter;
import com.joysw.view.TitleBarView;
/**
 * 
* @Title: MainActivity.java 
* @Package com.joysw.ui 
* @Description: 订单页面
* @author LIMINGYAN  
* @date 2015年3月28日 上午7:39:14 
* @version V1.0
 */
public class GoodsSearchActivity extends BaseActivity{
	@InjectView(R.id.goods_search_title_bar)
	TitleBarView title_bar_view;
	@InjectView(R.id.view_for_goods_classification)
	ExpandableListView expandListview;
	
	
	private ArrayList<String> groupArray;
	private ArrayList<List<String>> childArray;
	
	@Override
    protected void onCreate(Bundle arg0) {
    	// TODO Auto-generated method stub
    	super.onCreate(arg0);
    	setContentView(R.layout.activity_goods_search);
    	ButterKnife.inject(this);
    	
    	initView();
    }

private void initView() {
	title_bar_view.setTitleText(R.string.goods_search_title);
	title_bar_view.setBtnLeft(R.drawable.ic_back, R.string.back);
	title_bar_view.setBtnLeftOnclickListener(new OnClickListener() {

		@Override
		public void onClick(View arg0) {
			finish();
		}
	});
	
	List<String> groups = new ArrayList<String>();
	groups.add("橘子");
	groups.add("橙子");

	//准备第一个一级列表中的二级列表数据:两个二级列表,分别显示"橘子1"和"橘子2"
	List<Map<String, String>> child1 = new ArrayList<Map<String, String>>();
	Map<String, String> child1Data1 = new HashMap<String, String>();
	child1Data1.put("child", "橘子1");
	Map<String, String> child1Data2 = new HashMap<String, String>();
	child1Data2.put("child", "橘子2");
	child1.add(child1Data1);
	child1.add(child1Data2);

	//准备第二个一级列表中的二级列表数据:一个二级列表,显示"橙子1"
	List<Map<String, String>> child2 = new ArrayList<Map<String, String>>();
	Map<String, String> child2Data1 = new HashMap<String, String>();
	child2Data1.put("child", "橙子1");
	child2.add(child2Data1);

	//用一个list对象保存所有的二级列表数据
	List<List<Map<String, String>>> childs = new ArrayList<List<Map<String, String>>>();
	childs.add(child1);
	childs.add(child2);

	ExpandableListAdapter viewAdapter = new ExpandableListAdapter(this, groups, childs);
	expandListview.setAdapter(viewAdapter);
	
}


}
